package org.chen.spring.aop;

import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * 切面通知类
 *
 * @author Chen
 * @since 2023/6/8 15:41
 */
public class ProceedingJoinPoint extends JoinPoint {

    private final Object target;

    private final MethodProxy methodProxy;

    public ProceedingJoinPoint(Method method, Object[] args, Object target, MethodProxy methodProxy) {
        super(method, args);
        this.target = target;
        this.methodProxy = methodProxy;
    }

    public Object proceed() {
        try {
            return methodProxy.invokeSuper(target, getArgs());
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}
